home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / pseudoDoc / ExampleHeaders / CFDictionary.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  32.7 KB  |  681 lines

  1. /*    CFDictionary.h
  2.     Copyright 1998-1999, Apple Computer, Inc. All rights reserved.
  3. */
  4.  
  5. /*!
  6.     @header CFDictionary
  7.     CFDictionary implements a container which pairs pointer-sized keys
  8.     with pointer-sized values. Values are accessed via arbitrary
  9.     user-defined keys. A CFDictionary differs from a CFArray in that
  10.     the key used to access a particular value in the dictionary remains
  11.     the same as values are added to or removed from the dictionary,
  12.     unless a value associated with its particular key is replaced or
  13.     removed. In a CFArray, the key (or index) used to retrieve a
  14.     particular value can change over time as values are added to or
  15.     deleted from the array. Also unlike an array, there is no ordering
  16.     among values in a dictionary. To enable later retrieval of a value,
  17.     the key of the key-value pair should be constant (or treated as
  18.     constant); if the key changes after being used to put a value in
  19.     the dictionary, the value may not be retrievable. The keys of a
  20.     dictionary form a set; that is, no two keys which are equal to
  21.     one another are present in the dictionary at any time.
  22.  
  23.     Dictionaries come in two flavors, immutable, which cannot have
  24.     values added to them or removed from them after the dictionary is
  25.     created, and mutable, to which you can add values or from which
  26.     remove values. Mutable dictionaries have two subflavors,
  27.     fixed-capacity, for which there is a maximum number set at creation
  28.     time of values which can be put into the dictionary, and variable
  29.     capacity, which can have an unlimited number of values (or rather,
  30.     limited only by constraints external to CFDictionary, like the
  31.     amount of available memory). Fixed-capacity dictionaries can be
  32.     somewhat higher performing, if you can put a definate upper limit
  33.     on the number of values that might be put into the dictionary.
  34.  
  35.     As with all CoreFoundation collection types, dictionaries maintain
  36.     hard references on the values you put in them, but the retaining and
  37.     releasing functions are user-defined callbacks that can actually do
  38.     whatever the user wants (for example, nothing).
  39.  
  40.     Although a particular implementation of CFDictionary may not use
  41.     hashing and a hash table for storage of the values, the keys have
  42.     a hash-code generating function defined for them, and a function
  43.     to test for equality of two keys. These two functions together
  44.     must maintain the invariant that if equal(X, Y), then hash(X) ==
  45.     hash(Y). Note that the converse will not generally be true (but
  46.     the contrapositive, if hash(X) != hash(Y), then !equal(X, Y),
  47.     will be as required by Boolean logic). If the hash() and equal()
  48.     key callbacks are NULL, the key is used as a pointer-sized integer,
  49.     and pointer equality is used. Care should be taken to provide a
  50.     hash() callback which will compute sufficiently dispersed hash
  51.     codes for the key set for best performance.
  52.  
  53.     Computational Complexity
  54.     The access time for a value in the dictionary is guaranteed to be at
  55.     worst O(lg N) for any implementation, current and future, but will
  56.     often be O(1) (constant time). Insertion or deletion operations
  57.     will typically be constant time as well, but are O(N*lg N) in the
  58.     worst case in some implementations. Access of values through a key
  59.     is faster than accessing values directly (if there are any such
  60.     operations). Dictionaries will tend to use significantly more memory
  61.     than a array with the same number of values.
  62. */
  63.  
  64. #if !defined(__COREFOUNDATION_CFDICTIONARY__)
  65. #define __COREFOUNDATION_CFDICTIONARY__ 1
  66.  
  67. #include <CoreFoundation/CFBase.h>
  68.  
  69. #if defined(__cplusplus)
  70. extern "C" {
  71. #endif
  72.  
  73. /*!
  74.     @typedef CFDictionaryKeyCallBacks
  75.     Structure containing the callbacks for keys of a CFDictionary.
  76.     @field version The version number of the structure type being passed
  77.         in as a parameter to the CFDictionary creation functions.
  78.         This structure is version 0.
  79.     @field retain The callback used to add a retain for the dictionary
  80.         on keys as they are used to put values into the dictionary.
  81.         This callback returns the value to use as the key in the
  82.         dictionary, which is usually the value parameter passed to
  83.         this callback, but may be a different value if a different
  84.         value should be used as the key. The dictionary's allocator
  85.         is passed as the first argument.
  86.     @field release The callback used to remove a retain previously added
  87.         for the dictionary from keys as their values are removed from
  88.         the dictionary. The dictionary's allocator is passed as the
  89.         first argument.
  90.     @field copyDescription The callback used to create a descriptive
  91.         string representation of each key in the dictionary. This
  92.         is used by the CFCopyDescription() function.
  93.     @field equal The callback used to compare keys in the dictionary for
  94.         equality.
  95.     @field hash The callback used to compute a hash code for keys as they
  96.         are used to access, add, or remove values in the dictionary.
  97. */
  98. typedef const void *    (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
  99. typedef void        (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
  100. typedef CFStringRef    (*CFDictionaryCopyDescriptionCallBack)(const void *value);
  101. typedef Boolean        (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
  102. typedef CFHashCode    (*CFDictionaryHashCallBack)(const void *value);
  103. typedef struct {
  104.     CFIndex                version;
  105.     CFDictionaryRetainCallBack        retain;
  106.     CFDictionaryReleaseCallBack        release;
  107.     CFDictionaryCopyDescriptionCallBack    copyDescription;
  108.     CFDictionaryEqualCallBack        equal;
  109.     CFDictionaryHashCallBack        hash;
  110. } CFDictionaryKeyCallBacks;
  111.  
  112. /*!
  113.     @constant kCFTypeDictionaryKeyCallBacks
  114.     Predefined CFDictionaryKeyCallBacks structure containing a
  115.     set of callbacks appropriate for use when the keys of a
  116.     CFDictionary are all CFTypes.
  117. */
  118. CF_EXPORT
  119. const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
  120.  
  121. /*!
  122.     @constant kCFCopyStringDictionaryKeyCallBacks
  123.     Predefined CFDictionaryKeyCallBacks structure containing a
  124.     set of callbacks appropriate for use when the keys of a
  125.     CFDictionary are all CFStrings, which may be mutable and
  126.     need to be copied in order to serve as constant keys for
  127.     the values in the dictionary.
  128. */
  129. CF_EXPORT
  130. const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
  131.  
  132. /*!
  133.     @typedef CFDictionaryValueCallBacks
  134.     Structure containing the callbacks for values of a CFDictionary.
  135.     @field version The version number of the structure type being passed
  136.         in as a parameter to the CFDictionary creation functions.
  137.         This structure is version 0.
  138.     @field retain The callback used to add a retain for the dictionary
  139.         on values as they are put into the dictionary.
  140.         This callback returns the value to use as the value in the
  141.         dictionary, which is usually the value parameter passed to
  142.         this callback, but may be a different value if a different
  143.         value should be added to the dictionary. The dictionary's
  144.         allocator is passed as the first argument.
  145.     @field release The callback used to remove a retain previously added
  146.         for the dictionary from values as they are removed from
  147.         the dictionary. The dictionary's allocator is passed as the
  148.         first argument.
  149.     @field copyDescription The callback used to create a descriptive
  150.         string representation of each value in the dictionary. This
  151.         is used by the CFCopyDescription() function.
  152.     @field equal The callback used to compare values in the dictionary for
  153.         equality in some operations.
  154. */
  155. typedef struct {
  156.     CFIndex                version;
  157.     CFDictionaryRetainCallBack        retain;
  158.     CFDictionaryReleaseCallBack        release;
  159.     CFDictionaryCopyDescriptionCallBack    copyDescription;
  160.     CFDictionaryEqualCallBack        equal;
  161. } CFDictionaryValueCallBacks;
  162.  
  163. /*!
  164.     @constant kCFTypeDictionaryValueCallBacks
  165.     Predefined CFDictionaryValueCallBacks structure containing a set
  166.     of callbacks appropriate for use when the values in a CFDictionary
  167.     are all CFTypes.
  168. */
  169. CF_EXPORT
  170. const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
  171.  
  172. /*!
  173.     @typedef CFDictionaryApplierFunction
  174.     Type of the callback function used by the apply functions of
  175.         CFDictionarys.
  176.     @param key The current key for the value.
  177.     @param val The current value from the dictionary.
  178.     @param context The user-defined context parameter given to the apply
  179.         function.
  180. */
  181. typedef void (*CFDictionaryApplierFunction)(const void *key, const void *value, void *context);
  182.  
  183. /*!
  184.     @typedef CFDictionaryRef
  185.     This is the type of a reference to immutable CFDictionarys.
  186. */
  187. typedef const struct __CFDictionary * CFDictionaryRef;
  188.  
  189. /*!
  190.     @typedef CFMutableDictionaryRef
  191.     This is the type of a reference to mutable CFDictionarys.
  192. */
  193. typedef struct __CFDictionary * CFMutableDictionaryRef;
  194.  
  195. /*!
  196.     @function CFDictionaryGetTypeID
  197.     Returns the type identifier of all CFDictionary instances.
  198. */
  199. CF_EXPORT
  200. CFTypeID CFDictionaryGetTypeID(void);
  201.  
  202. /*!
  203.     @function CFDictionaryCreate
  204.     Creates a new immutable dictionary with the given values.
  205.     @param allocator The CFAllocator which should be used to allocate
  206.         memory for the dictionary and its storage for values. This
  207.         parameter may be NULL in which case the current default
  208.         CFAllocator is used. If this reference is not a valid
  209.         CFAllocator, the behavior is undefined.
  210.     @param keys A C array of the pointer-sized keys to be used for
  211.         the parallel C array of values to be put into the dictionary.
  212.         This parameter may be NULL if the numValues parameter is 0.
  213.         This C array is not changed or freed by this function. If
  214.         this parameter is not a valid pointer to a C array of at
  215.         least numValues pointers, the behavior is undefined.
  216.     @param values A C array of the pointer-sized values to be in the
  217.         dictionary. This parameter may be NULL if the numValues
  218.         parameter is 0. This C array is not changed or freed by
  219.         this function. If this parameter is not a valid pointer to
  220.         a C array of at least numValues pointers, the behavior is
  221.         undefined.
  222.     @param numValues The number of values to copy from the keys and
  223.         values C arrays into the CFDictionary. This number will be
  224.         the count of the dictionary. If this parameter is
  225.         negative, or greater than the number of values actually
  226.         in the keys or values C arrays, the behavior is undefined.
  227.     @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  228.         initialized with the callbacks for the dictionary to use on
  229.         each key in the dictionary. The retain callback will be used
  230.         within this function, for example, to retain all of the new
  231.         keys from the keys C array. A copy of the contents of the
  232.         callbacks structure is made, so that a pointer to a structure
  233.         on the stack can be passed in, or can be reused for multiple
  234.         dictionary creations. If the version field of this
  235.         callbacks structure is not one of the defined ones for
  236.         CFDictionary, the behavior is undefined. The retain field may
  237.         be NULL, in which case the CFDictionary will do nothing to add
  238.         a retain to the keys of the contained values. The release field
  239.         may be NULL, in which case the CFDictionary will do nothing
  240.         to remove the dictionary's retain (if any) on the keys when the
  241.         dictionary is destroyed or a key-value pair is removed. If the
  242.         copyDescription field is NULL, the dictionary will create a
  243.         simple description for a key. If the equal field is NULL, the
  244.         dictionary will use pointer equality to test for equality of
  245.         keys. If the hash field is NULL, a key will be converted from
  246.         a pointer to an integer to compute the hash code. This callbacks
  247.         parameter itself may be NULL, which is treated as if a valid
  248.         structure of version 0 with all fields NULL had been passed in.
  249.         Otherwise, if any of the fields are not valid pointers to
  250.         functions of the correct type, or this parameter is not a
  251.         valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  252.         the behavior is undefined. If any of the keys put into the
  253.         dictionary is not one understood by one of the callback functions
  254.         the behavior when that callback function is used is undefined.
  255.     @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  256.         initialized with the callbacks for the dictionary to use on
  257.         each value in the dictionary. The retain callback will be used
  258.         within this function, for example, to retain all of the new
  259.         values from the values C array. A copy of the contents of the
  260.         callbacks structure is made, so that a pointer to a structure
  261.         on the stack can be passed in, or can be reused for multiple
  262.         dictionary creations. If the version field of this callbacks
  263.         structure is not one of the defined ones for CFDictionary, the
  264.         behavior is undefined. The retain field may be NULL, in which
  265.         case the CFDictionary will do nothing to add a retain to values
  266.         as they are put into the dictionary. The release field may be
  267.         NULL, in which case the CFDictionary will do nothing to remove
  268.         the dictionary's retain (if any) on the values when the
  269.         dictionary is destroyed or a key-value pair is removed. If the
  270.         copyDescription field is NULL, the dictionary will create a
  271.         simple description for a value. If the equal field is NULL, the
  272.         dictionary will use pointer equality to test for equality of
  273.         values. This callbacks parameter itself may be NULL, which is
  274.         treated as if a valid structure of version 0 with all fields
  275.         NULL had been passed in. Otherwise,
  276.         if any of the fields are not valid pointers to functions
  277.         of the correct type, or this parameter is not a valid
  278.         pointer to a CFDictionaryValueCallBacks callbacks structure,
  279.         the behavior is undefined. If any of the values put into the
  280.         dictionary is not one understood by one of the callback functions
  281.         the behavior when that callback function is used is undefined.
  282.     @result A reference to the new immutable CFDictionary.
  283. */
  284. CF_EXPORT
  285. CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
  286.  
  287. /*!
  288.     @function CFDictionaryCreateCopy
  289.     Creates a new immutable dictionary with the key-value pairs from
  290.         the given dictionary.
  291.     @param allocator The CFAllocator which should be used to allocate
  292.         memory for the dictionary and its storage for values. This
  293.         parameter may be NULL in which case the current default
  294.         CFAllocator is used. If this reference is not a valid
  295.         CFAllocator, the behavior is undefined.
  296.     @param theDict The dictionary which is to be copied. The keys and values
  297.         from the dictionary are copied as pointers into the new
  298.         dictionary (that is, the values themselves are copied, not
  299.         that which the values point to, if anything). However, the
  300.         keys and values are also retained by the new dictionary using
  301.         the retain function of the original dictionary.
  302.         The count of the new dictionary will be the same as the
  303.         given dictionary. The new dictionary uses the same callbacks
  304.         as the dictionary to be copied. If this parameter is
  305.         not a valid CFDictionary, the behavior is undefined.
  306.     @result A reference to the new immutable CFDictionary.
  307. */
  308. CF_EXPORT
  309. CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef theDict);
  310.  
  311. /*!
  312.     @function CFDictionaryCreateMutable
  313.     Creates a new mutable dictionary.
  314.     @param allocator The CFAllocator which should be used to allocate
  315.         memory for the dictionary and its storage for values. This
  316.         parameter may be NULL in which case the current default
  317.         CFAllocator is used. If this reference is not a valid
  318.         CFAllocator, the behavior is undefined.
  319.     @param capacity The maximum number of values that can be contained by
  320.         the CFDictionary. The dictionary starts empty, and can grow
  321.         to this number of values (and it can have less). If this
  322.         parameter is 0, the dictionary's maximum capacity is unlimited
  323.         (or rather, only limited by address space and available memory
  324.         constraints). If this parameter is negative, the behavior is
  325.         undefined.
  326.     @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  327.         initialized with the callbacks for the dictionary to use on
  328.         each key in the dictionary. A copy of the contents of the
  329.         callbacks structure is made, so that a pointer to a structure
  330.         on the stack can be passed in, or can be reused for multiple
  331.         dictionary creations. If the version field of this
  332.         callbacks structure is not one of the defined ones for
  333.         CFDictionary, the behavior is undefined. The retain field may
  334.         be NULL, in which case the CFDictionary will do nothing to add
  335.         a retain to the keys of the contained values. The release field
  336.         may be NULL, in which case the CFDictionary will do nothing
  337.         to remove the dictionary's retain (if any) on the keys when the
  338.         dictionary is destroyed or a key-value pair is removed. If the
  339.         copyDescription field is NULL, the dictionary will create a
  340.         simple description for a key. If the equal field is NULL, the
  341.         dictionary will use pointer equality to test for equality of
  342.         keys. If the hash field is NULL, a key will be converted from
  343.         a pointer to an integer to compute the hash code. This callbacks
  344.         parameter itself may be NULL, which is treated as if a valid
  345.         structure of version 0 with all fields NULL had been passed in.
  346.         Otherwise, if any of the fields are not valid pointers to
  347.         functions of the correct type, or this parameter is not a
  348.         valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  349.         the behavior is undefined. If any of the keys put into the
  350.         dictionary is not one understood by one of the callback functions
  351.         the behavior when that callback function is used is undefined.
  352.     @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  353.         initialized with the callbacks for the dictionary to use on
  354.         each value in the dictionary. The retain callback will be used
  355.         within this function, for example, to retain all of the new
  356.         values from the values C array. A copy of the contents of the
  357.         callbacks structure is made, so that a pointer to a structure
  358.         on the stack can be passed in, or can be reused for multiple
  359.         dictionary creations. If the version field of this callbacks
  360.         structure is not one of the defined ones for CFDictionary, the
  361.         behavior is undefined. The retain field may be NULL, in which
  362.         case the CFDictionary will do nothing to add a retain to values
  363.         as they are put into the dictionary. The release field may be
  364.         NULL, in which case the CFDictionary will do nothing to remove
  365.         the dictionary's retain (if any) on the values when the
  366.         dictionary is destroyed or a key-value pair is removed. If the
  367.         copyDescription field is NULL, the dictionary will create a
  368.         simple description for a value. If the equal field is NULL, the
  369.         dictionary will use pointer equality to test for equality of
  370.         values. This callbacks parameter itself may be NULL, which is
  371.         treated as if a valid structure of version 0 with all fields
  372.         NULL had been passed in. Otherwise,
  373.         if any of the fields are not valid pointers to functions
  374.         of the correct type, or this parameter is not a valid
  375.         pointer to a CFDictionaryValueCallBacks callbacks structure,
  376.         the behavior is undefined. If any of the values put into the
  377.         dictionary is not one understood by one of the callback functions
  378.         the behavior when that callback function is used is undefined.
  379.     @result A reference to the new mutable CFDictionary.
  380. */
  381. CF_EXPORT
  382. CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
  383.  
  384. /*!
  385.     @function CFDictionaryCreateMutableCopy
  386.     Creates a new mutable dictionary with the key-value pairs from
  387.         the given dictionary.
  388.     @param allocator The CFAllocator which should be used to allocate
  389.         memory for the dictionary and its storage for values. This
  390.         parameter may be NULL in which case the current default
  391.         CFAllocator is used. If this reference is not a valid
  392.         CFAllocator, the behavior is undefined.
  393.     @param capacity The maximum number of values that can be contained
  394.         by the CFDictionary. The dictionary starts empty, and can grow
  395.         to this number of values (and it can have less). If this
  396.         parameter is 0, the dictionary's maximum capacity is unlimited
  397.         (or rather, only limited by address space and available memory
  398.         constraints). This parameter must be greater than or equal
  399.         to the count of the dictionary which is to be copied, or the
  400.         behavior is undefined. If this parameter is negative, the
  401.         behavior is undefined.
  402.     @param theDict The dictionary which is to be copied. The keys and values
  403.         from the dictionary are copied as pointers into the new
  404.         dictionary (that is, the values themselves are copied, not
  405.         that which the values point to, if anything). However, the
  406.         keys and values are also retained by the new dictionary using
  407.         the retain function of the original dictionary.
  408.         The count of the new dictionary will be the same as the
  409.         given dictionary. The new dictionary uses the same callbacks
  410.         as the dictionary to be copied. If this parameter is
  411.         not a valid CFDictionary, the behavior is undefined.
  412.     @result A reference to the new mutable CFDictionary.
  413. */
  414. CF_EXPORT
  415. CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict);
  416.  
  417. /*!
  418.     @function CFDictionaryGetCount
  419.     Returns the number of values currently in the dictionary.
  420.     @param theDict The dictionary to be queried. If this parameter is
  421.         not a valid CFDictionary, the behavior is undefined.
  422.     @result The number of values in the dictionary.
  423. */
  424. CF_EXPORT
  425. CFIndex CFDictionaryGetCount(CFDictionaryRef theDict);
  426.  
  427. /*!
  428.     @function CFDictionaryGetCountOfKey
  429.     Counts the number of times the given key occurs in the dictionary.
  430.     @param theDict The dictionary to be searched. If this parameter is
  431.         not a valid CFDictionary, the behavior is undefined.
  432.     @param key The key for which to find matches in the dictionary. The
  433.         hash() and equal() key callbacks provided when the dictionary
  434.         was created are used to compare. If the hash() key callback
  435.         was NULL, the key is treated as a pointer and converted to
  436.         an integer. If the equal() key callback was NULL, pointer
  437.         equality (in C, ==) is used. If key, or any of the keys in
  438.         the dictionary, are not understood by the equal() callback,
  439.         the behavior is undefined.
  440.     @result Returns 1 if a matching key is used by the dictionary,
  441.         0 otherwise.
  442. */
  443. CF_EXPORT
  444. CFIndex CFDictionaryGetCountOfKey(CFDictionaryRef theDict, const void *key);
  445.  
  446. /*!
  447.     @function CFDictionaryGetCountOfValue
  448.     Counts the number of times the given value occurs in the dictionary.
  449.     @param theDict The dictionary to be searched. If this parameter is
  450.         not a valid CFDictionary, the behavior is undefined.
  451.     @param value The value for which to find matches in the dictionary. The
  452.         equal() callback provided when the dictionary was created is
  453.         used to compare. If the equal() value callback was NULL, pointer
  454.         equality (in C, ==) is used. If value, or any of the values in
  455.         the dictionary, are not understood by the equal() callback,
  456.         the behavior is undefined.
  457.     @result The number of times the given value occurs in the dictionary.
  458. */
  459. CF_EXPORT
  460. CFIndex CFDictionaryGetCountOfValue(CFDictionaryRef theDict, const void *value);
  461.  
  462. /*!
  463.     @function CFDictionaryContainsKey
  464.     Reports whether or not the key is in the dictionary.
  465.     @param theDict The dictionary to be searched. If this parameter is
  466.         not a valid CFDictionary, the behavior is undefined.
  467.     @param key The key for which to find matches in the dictionary. The
  468.         hash() and equal() key callbacks provided when the dictionary
  469.         was created are used to compare. If the hash() key callback
  470.         was NULL, the key is treated as a pointer and converted to
  471.         an integer. If the equal() key callback was NULL, pointer
  472.         equality (in C, ==) is used. If key, or any of the keys in
  473.         the dictionary, are not understood by the equal() callback,
  474.         the behavior is undefined.
  475.     @result TRUE, if the key is in the dictionary, otherwise FALSE.
  476. */
  477. CF_EXPORT
  478. Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key);
  479.  
  480. /*!
  481.     @function CFDictionaryContainsValue
  482.     Reports whether or not the value is in the dictionary.
  483.     @param theDict The dictionary to be searched. If this parameter is
  484.         not a valid CFDictionary, the behavior is undefined.
  485.     @param value The value for which to find matches in the dictionary. The
  486.         equal() callback provided when the dictionary was created is
  487.         used to compare. If the equal() callback was NULL, pointer
  488.         equality (in C, ==) is used. If value, or any of the values
  489.         in the dictionary, are not understood by the equal() callback,
  490.         the behavior is undefined.
  491.     @result TRUE, if the value is in the dictionary, otherwise FALSE.
  492. */
  493. CF_EXPORT
  494. Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value);
  495.  
  496. /*!
  497.     @function CFDictionaryGetValue
  498.     Retrieves the value associated with the given key.
  499.     @param theDict The dictionary to be queried. If this parameter is
  500.         not a valid CFDictionary, the behavior is undefined.
  501.     @param key The key for which to find a match in the dictionary. The
  502.         hash() and equal() key callbacks provided when the dictionary
  503.         was created are used to compare. If the hash() key callback
  504.         was NULL, the key is treated as a pointer and converted to
  505.         an integer. If the equal() key callback was NULL, pointer
  506.         equality (in C, ==) is used. If key, or any of the keys in
  507.         the dictionary, are not understood by the equal() callback,
  508.         the behavior is undefined.
  509.     @result The value with the given key in the dictionary, or NULL if
  510.         no key-value pair with a matching key exists. Since NULL
  511.         can be a valid value in some dictionaries, the function
  512.         CFDictionaryGetValueIfPresent() must be used to distinguish
  513.         NULL-no-found from NULL-is-the-value.
  514. */
  515. CF_EXPORT
  516. const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
  517.  
  518. /*!
  519.     @function CFDictionaryGetValueIfPresent
  520.     Retrieves the value associated with the given key.
  521.     @param theDict The dictionary to be queried. If this parameter is
  522.         not a valid CFDictionary, the behavior is undefined.
  523.     @param key The key for which to find a match in the dictionary. The
  524.         hash() and equal() key callbacks provided when the dictionary
  525.         was created are used to compare. If the hash() key callback
  526.         was NULL, the key is treated as a pointer and converted to
  527.         an integer. If the equal() key callback was NULL, pointer
  528.         equality (in C, ==) is used. If key, or any of the keys in
  529.         the dictionary, are not understood by the equal() callback,
  530.         the behavior is undefined.
  531.     @param value A pointer to memory which should be filled with the
  532.         pointer-sized value if a matching key is found. If no key
  533.         match is found, the contents of the storage pointed to by
  534.         this parameter are undefined. This parameter may be NULL,
  535.         in which case the value from the dictionary is not returned
  536.         (but the return value of this function still indicates
  537.         whether or not the key-value pair was present).
  538.     @result TRUE, if a matching key was found, FALSE otherwise.
  539. */
  540. CF_EXPORT
  541. Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value);
  542.  
  543. /*!
  544.     @function CFDictionaryGetKeysAndValues
  545.     Fills the two buffers with the keys and values from the dictionary.
  546.     @param theDict The dictionary to be queried. If this parameter is
  547.         not a valid CFDictionary, the behavior is undefined.
  548.     @param keys A C array of pointer-sized values to be filled with keys
  549.         from the dictionary. The keys and values C arrays are parallel
  550.         to each other (that is, the items at the same indices form a
  551.         key-value pair from the dictionary). This parameter may be NULL
  552.         if the keys are not desired. If this parameter is not a valid
  553.         pointer to a C array of at least CFDictionaryGetCount() pointers,
  554.         or NULL, the behavior is undefined.
  555.     @param values A C array of pointer-sized values to be filled with values
  556.         from the dictionary. The keys and values C arrays are parallel
  557.         to each other (that is, the items at the same indices form a
  558.         key-value pair from the dictionary). This parameter may be NULL
  559.         if the values are not desired. If this parameter is not a valid
  560.         pointer to a C array of at least CFDictionaryGetCount() pointers,
  561.         or NULL, the behavior is undefined.
  562. */
  563. CF_EXPORT
  564. void CFDictionaryGetKeysAndValues(CFDictionaryRef theDict, const void **keys, const void **values);
  565.  
  566. /*!
  567.     @function CFDictionaryApplyFunction
  568.     Calls a function once for each value in the dictionary.
  569.     @param theDict The dictionary to be queried. If this parameter is
  570.         not a valid CFDictionary, the behavior is undefined.
  571.     @param applier The callback function to call once for each value in
  572.         the dictionary. If this parameter is not a
  573.         pointer to a function of the correct prototype, the behavior
  574.         is undefined. If there are keys or values which the
  575.         applier function does not expect or cannot properly apply
  576.         to, the behavior is undefined. 
  577.     @param context A pointer-sized user-defined value, which is passed
  578.         as the third parameter to the applier function, but is
  579.         otherwise unused by this function. If the context is not
  580.         what is expected by the applier function, the behavior is
  581.         undefined.
  582. */
  583. CF_EXPORT
  584. void CFDictionaryApplyFunction(CFDictionaryRef theDict, CFDictionaryApplierFunction applier, void *context);
  585.  
  586. /*!
  587.     @function CFDictionaryAddValue
  588.     Adds the key-value pair to the dictionary if no such key already exists.
  589.     @param theDict The dictionary to which the value is to be added. If this
  590.         parameter is not a valid mutable CFDictionary, the behavior is
  591.         undefined. If the dictionary is a fixed-capacity dictionary and
  592.         it is full before this operation, the behavior is undefined.
  593.     @param key The key of the value to add to the dictionary. The key is
  594.         retained by the dictionary using the retain callback provided
  595.         when the dictionary was created. If the key is not of the sort
  596.         expected by the retain callback, the behavior is undefined. If
  597.         a key which matches this key is already present in the dictionary,
  598.         this function does nothing ("add if absent").
  599.     @param value The value to add to the dictionary. The value is retained
  600.         by the dictionary using the retain callback provided when the
  601.         dictionary was created. If the value is not of the sort expected
  602.         by the retain callback, the behavior is undefined.
  603. */
  604. CF_EXPORT
  605. void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
  606.  
  607. /*!
  608.     @function CFDictionarySetValue
  609.     Sets the value of the key in the dictionary.
  610.     @param theDict The dictionary to which the value is to be set. If this
  611.         parameter is not a valid mutable CFDictionary, the behavior is
  612.         undefined. If the dictionary is a fixed-capacity dictionary and
  613.         it is full before this operation, and the key does not exist in
  614.         the dictionary, the behavior is undefined.
  615.     @param key The key of the value to set into the dictionary. If a key 
  616.         which matches this key is already present in the dictionary, only
  617.         the value is changed ("add if absent, replace if present"). If
  618.         no key matches the given key, the key-value pair is added to the
  619.         dictionary. If added, the key is retained by the dictionary,
  620.         using the retain callback provided
  621.         when the dictionary was created. If the key is not of the sort
  622.         expected by the key retain callback, the behavior is undefined.
  623.     @param value The value to add to or replace into the dictionary. The value
  624.         is retained by the dictionary using the retain callback provided
  625.         when the dictionary was created, and the previous value if any is
  626.         released. If the value is not of the sort expected by the
  627.         retain or release callbacks, the behavior is undefined.
  628. */
  629. CF_EXPORT
  630. void CFDictionarySetValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
  631.  
  632. /*!
  633.     @function CFDictionaryReplaceValue
  634.     Replaces the value of the key in the dictionary.
  635.     @param theDict The dictionary to which the value is to be replaced. If this
  636.         parameter is not a valid mutable CFDictionary, the behavior is
  637.         undefined.
  638.     @param key The key of the value to replace in the dictionary. If a key 
  639.         which matches this key is present in the dictionary, the value
  640.         is changed to the given value, otherwise this function does
  641.         nothing ("replace if present").
  642.     @param value The value to replace into the dictionary. The value
  643.         is retained by the dictionary using the retain callback provided
  644.         when the dictionary was created, and the previous value is
  645.         released. If the value is not of the sort expected by the
  646.         retain or release callbacks, the behavior is undefined.
  647. */
  648. CF_EXPORT
  649. void CFDictionaryReplaceValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
  650.  
  651. /*!
  652.     @function CFDictionaryRemoveValue
  653.     Removes the value of the key from the dictionary.
  654.     @param theDict The dictionary from which the value is to be removed. If this
  655.         parameter is not a valid mutable CFDictionary, the behavior is
  656.         undefined.
  657.     @param key The key of the value to remove from the dictionary. If a key 
  658.         which matches this key is present in the dictionary, the key-value
  659.         pair is removed from the dictionary, otherwise this function does
  660.         nothing ("remove if present").
  661. */
  662. CF_EXPORT
  663. void CFDictionaryRemoveValue(CFMutableDictionaryRef theDict, const void *key);
  664.  
  665. /*!
  666.     @function CFDictionaryRemoveAllValues
  667.     Removes all the values from the dictionary, making it empty.
  668.     @param theDict The dictionary from which all of the values are to be
  669.         removed. If this parameter is not a valid mutable
  670.         CFDictionary, the behavior is undefined.
  671. */
  672. CF_EXPORT
  673. void CFDictionaryRemoveAllValues(CFMutableDictionaryRef theDict);
  674.  
  675. #if defined(__cplusplus)
  676. }
  677. #endif
  678.  
  679. #endif /* ! __COREFOUNDATION_CFDICTIONARY__ */
  680.  
  681.